Skip to main content

df command

df - report file system disk space usage

The df command in Linux is a utility used to display disk space usage for mounted filesystems. It’s essential for checking how much space is available, used, or free on your drives.

Usage: df [OPTION]... [FILE]...

  • FILE: Optional path to a file or directory to report its filesystem (if omitted, shows all mounted filesystems).
  • OPTION: Flags to modify output format or content.

Common Options

OptionDescription
-hHuman-readable sizes (e.g., GB, MB)
-TShow filesystem type
--totalAdd a total summary row
-tInclude only specific types
-xExclude specific types
-iShow inode usage instead of blocks

Examples

  • Basic Usage

    Run df without options to see disk usage for all mounted filesystems in 512-byte blocks.

    df
    • Output (example):
      Filesystem     1K-blocks    Used Available Use% Mounted on
      /dev/sda1 104857600 52428800 52428800 50% /
      /dev/sdb1 20971520 1048576 19922944 5% /mnt/data
    • Explanation:
      • Filesystem: Device or mount point.
      • 1K-blocks: Total size in kilobytes.
      • Used: Space used.
      • Available: Space free.
      • Use%: Percentage used.
      • Mounted on: Mount point.
  • Human-Readable Output

    Use -h to display sizes in a more readable format (e.g., GB, MB).

    df -h
    • Output:
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1 100G 50G 50G 50% /
      /dev/sdb1 20G 1.0G 19G 5% /mnt/data
    • Sizes are shown as G (gigabytes), M (megabytes), etc.
  • Specific Filesystem

    Pass a file or directory to see only its filesystem.

    df -h /mnt/data
    • Output:
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sdb1 20G 1.0G 19G 5% /mnt/data
  • Show Filesystem Type

    Use -T to include the filesystem type (e.g., ext4, ntfs).

    df -hT
    • Output:
      Filesystem     Type      Size  Used Avail Use% Mounted on
      /dev/sda1 ext4 100G 50G 50G 50% /
      /dev/sdb1 ntfs 20G 1.0G 19G 5% /mnt/data
  • Total Summary

    Use --total to add a summary row with totals.

    df -h --total
    • Output:
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1 100G 50G 50G 50% /
      /dev/sdb1 20G 1.0G 19G 5% /mnt/data
      total 120G 51G 69G 43% -
  • Filtering by Type

    Use -t to show only specific filesystem types.

    df -h -t ext4
    • Output:
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/sda1 100G 50G 50G 50% /
  • Excluding Types

    Use -x to exclude specific filesystem types (e.g., temporary filesystems like tmpfs).

    df -h -x tmpfs
    • Omits tmpfs entries often used for memory-based mounts.
$ df --help
Usage: df [OPTION]... [FILE]...
Show information about the file system on which each FILE resides,
or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.
-a, --all include pseudo, duplicate, inaccessible file systems
-B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'-BM' prints sizes in units of 1,048,576 bytes;
see SIZE format below
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)
-H, --si print sizes in powers of 1000 (e.g., 1.1G)
-i, --inodes list inode information instead of block usage
-k like --block-size=1K
-l, --local limit listing to local file systems
--no-sync do not invoke sync before getting usage info (default)
--output[=FIELD_LIST] use the output format defined by FIELD_LIST,
or print all fields if FIELD_LIST is omitted.
-P, --portability use the POSIX output format
--sync invoke sync before getting usage info
--total elide all entries insignificant to available space,
and produce a grand total
-t, --type=TYPE limit listing to file systems of type TYPE
-T, --print-type print file system type
-x, --exclude-type=TYPE limit listing to file systems not of type TYPE
-v (ignored)
--help display this help and exit
--version output version information and exit

Display values are in units of the first available SIZE from --block-size,
and the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables.
Otherwise, units default to 1024 bytes (or 512 if POSIXLY_CORRECT is set).

The SIZE argument is an integer and optional unit (example: 10K is 10*1024).
Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000).
Binary prefixes can be used, too: KiB=K, MiB=M, and so on.

FIELD_LIST is a comma-separated list of columns to be included. Valid
field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',
'size', 'used', 'avail', 'pcent', 'file' and 'target' (see info page).

For more details, check the manual with man df